package com.jack.thinking.thread.core._2;

public class StaticClassLock {
	public static void main(String[] args) {
		StaticClassLockObject o1 = new StaticClassLockObject();
		Thread t1 = new Thread() {
			@SuppressWarnings("static-access")
			@Override
			public void run() {
				try {
					o1.printA();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		};
		t1.start();
		
		
		
		StaticClassLockObject o2 = new StaticClassLockObject();
		Thread t2 = new Thread() {
			@SuppressWarnings("static-access")
			@Override
			public void run() {
				try {
					o2.printA();
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		};
		t2.start();
	}
}


class StaticClassLockObject{
	synchronized public static void printA() throws InterruptedException {
		System.out.println(Thread.currentThread().getName() + "RUNNING ----");
		Thread.sleep(1000L);
		System.out.println(Thread.currentThread().getName() + "END ----");
	}
}